'use strict';

var mvtRuOutlet = (function($){

  var addCtaToNavBar = function(){

    var layout_mode = $('.frame').length ? 'new' : 'legacy';

    if(layout_mode == 'legacy'){

      var legacy_floor_src = '' +
      '<li id="floor_3" class="men">' +
      '  <a style="color:rgb(223, 0, 0);" href="http://www.asos.com/Sale/Cat/pgehtml.aspx?cid=19259&WT.ac=Test2a|Sale|Tab|Legacy" id="mvt-outlet-cta" tabindex="4" title="Sale" class="">' +
      '  <span>Sale</span></a>' +
      '</li>';

      var $legacy_floor_html = $(legacy_floor_src);

      $('#floor_nav .floors').append($legacy_floor_html);

    }else if(layout_mode == 'new'){

      var new_floor_src = '' +
      '<li class="floor_3">' +
      '  <a style="color:rgb(223, 0, 0);" id="mvt-outlet-cta" href="http://www.asos.com/Sale/Cat/pgehtml.aspx?cid=19259&WT.ac=Test2a|Sale|Tab|HP"><span>Sale</span></a>' +
      '</li>';

      var $new_floor_html = $(new_floor_src);

      $('.floor-menus').append($new_floor_html);

    }else{
      return;
    }

  };

  var highlightOutletNav = function(){

    var isOutletLanding = (window.location.href.indexOf('Asos-Outlet') != -1);
    var isOutletPage = (window.location.href.indexOf('/Sale/') != -1);
    if(isOutletLanding || isOutletPage){
      $('#floor_1 a:eq(0), #floor_2 a:eq(0), #floor_3 a:eq(0)').removeClass('selected');
      $('#mvt-outlet-cta').addClass('selected');
    }

  };

  var init = function(){
    addCtaToNavBar();
    highlightOutletNav();
  };


  return {
    init:init
  };

})(jQuery);

jQuery(document).ready(function($) {
  mvtRuOutlet.init();
});
